//
//  SNBpDetailTableViewCell.m
//  project
//
//  Created by 黄建华 on 2017/12/8.
//  Copyright © 2017年 黄建华. All rights reserved.
//
#define SNHEARTBIG   [UIColor colorFromHex:0xf41628]
#define SNHEARTSMALL [UIColor colorFromHex:0xf99938]
#import "SNBpDetailTableViewCell.h"

@implementation SNBpDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    
    return self;
}

- (void)createView {
    _dateLabel = [[UILabel alloc] init];
    [self addSubview:_dateLabel];
    
    _valueLabel = [[UILabel alloc] init];
    [self addSubview:_valueLabel];
    
    _valueLabel2 = [[UILabel alloc] init];
    [self addSubview:_valueLabel2];
}

- (void)updateCellWithData:(NSArray *)data {
    _dateLabel.frame     = SNFRAME(30, 0, 150, 33);
    _dateLabel.textColor = SNCOLORBLACK;
    _dateLabel.font      = SNFONT(14.0);
    
    _valueLabel.frame         = SNFRAME(HHHWIDTH/3, 0, HHHWIDTH/3, 33);
    _valueLabel.textAlignment = NSTextAlignmentCenter;
    _valueLabel.font          = SNFONTMIN(12.0);
    
    _valueLabel2.frame         = SNFRAME(HHHWIDTH*2/3, 0, HHHWIDTH/3, 33);
    _valueLabel2.textAlignment = NSTextAlignmentCenter;
    _valueLabel2.font          = SNFONTMIN(12.0);
    
    _dateLabel.text = [data firstObject];
    
    int SBP = [[data objectAtIndex:1]integerValue];
    int DBP = [[data objectAtIndex:2]integerValue];
    _valueLabel.text  = [NSString stringWithFormat:@"%@  %d  mmHg", SN_Text(@"舒张压"), SBP];
    _valueLabel2.text = [NSString stringWithFormat:@"%@  %d  mmHg", SN_Text(@"收缩压"), DBP];
    if ([SN_PublicClass bpMinQuality:SBP] == 3) {
        _valueLabel.textColor = SNHEARTBIG;
    } else if ([SN_PublicClass bpMinQuality:SBP] == 2) {
        _valueLabel.textColor = SNCOLORBLACK;
    } else {
        _valueLabel.textColor = SNHEARTSMALL;
    }
    
    if ([SN_PublicClass bpMaxQuality:DBP] == 3) {
        _valueLabel2.textColor = SNHEARTBIG;
    } else if ([SN_PublicClass bpMaxQuality:DBP] == 2) {
        _valueLabel2.textColor = SNCOLORBLACK;
    } else {
        _valueLabel2.textColor = SNHEARTSMALL;
    }
}

@end

